#include <algorithm>
#include <cstdint>
#include <ios>
#include <string>
#include <vector>
#include <iostream>

using ull = uint64_t;

template<ull P=47,ull maxsize=(ull)1e3>
struct Hash{
    ull hash{};
    std::vector<ull> powp;
    Hash(const std::string&s):powp(maxsize){
        ull npp=P;
        powp[0]=1;
        powp[1]=npp;
        for(ull i=2;i<maxsize;i++){
            npp*=npp;
            powp[i]=npp;
        }
        ull k=0;
        for(auto it=s.rbegin();it!=s.rend();++it){
            hash+=((*it)-'A'+1)*powp[k];
        }
    }
    bool operator==(const Hash<P,maxsize>&o)const{
        return hash==o.hash;
    }
};

#define pv(v)do{std::cout<<std::boolalpha<<#v<<" :"<<(v)<<'\n';}while(0)

int main(){
    pv(Hash("aaaaaaaa")==Hash("aaaaaaa"));
}   